import * as mongoose from 'mongoose';

const CatSchema = new mongoose.Schema({
  name: String,
  age: Number,
  breed: String,
  parent: { type: mongoose.SchemaTypes.ObjectId, ref: 'Cat' },
});

CatSchema.virtual('children', {
  ref: 'Cat',
  localField: '_id',
  foreignField: 'parent',
  justOne: false,
});

CatSchema.set('toObject', { getters: true, virtuals: true });
CatSchema.set('toJSON', { getters: true, virtuals: true });

// module.exports = {CatSchema}
export { CatSchema };
